package operate;
import book.Book;
import book.BookList;
import user.User;
import java.util.Scanner;
//对书籍的操作
public class Add implements IOperate {
    /**
     * 负责人：青梅不甜
     * 功能：添加书籍
     * 让管理员把书籍信息（id,作者，书名，价格，类别，收藏和点赞默认为0）写入
     * 把书籍添加到bookList集合里
     * 参数：无
     * 返回类型：void
     */
    @Override
    public void operate(User user, BookList bookList) {
        System.out.println("请输入书名：");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();
        System.out.println("请输入作者：");
        String author = scanner.nextLine();
        System.out.println("请输入类别：");
        String type = scanner.nextLine();
        System.out.println("请输入价格：");
        double price = scanner.nextDouble();
        int size = bookList.bookLists.size() + 1;
        if(bookList.bookLists.size()!=0)
        {
            int tmp = bookList.bookLists.size()-1;
             size = bookList.bookLists.get(tmp).getId() + 1;
        }
        Book book = new Book(size, bookName, author, price, type, 0, 0);
        bookList.bookLists.add(book);
    }
}

